<?php

include_once "library/".Config::FOLDER_APPLICATION."/modules/newsletter/dao/NewsletterDAO.class.php"; 
include_once("library/facil3/core/controller/interface/HTTPControllerInterface.class.php");


class Newsletter implements HTTPControllerInterface{
	private $arrayRestFolder;
	
	public function __construct($arrayRestFolder = NULL){
		Config::getConection();
		if($arrayRestFolder != NULL){
			$this->arrayRestFolder = $arrayRestFolder;
			$this->arrayVariable   = Navigation::getVariableArraySlug($this->arrayRestFolder);
		}
	}
	
	public function init(){
		//
		
	}
	
	public function register(){
		
		$NewsletterDAO = NewsletterDAO::getInstance();
		
		if(Validation::validateEmail($_POST['emailMailing']) && Validation::blank($_POST['nameMailing'], 2)){
			$ReturnDataVO = $NewsletterDAO->insert( 1, $_POST['nameMailing'], $_POST['emailMailing'] ) ;
			if($ReturnDataVO->success){
				$tipo_de_registro = "newsletter";
				$nome 	= $_POST['nameMailing'];
				$email 	=  $_POST['emailMailing'];
				echo 'true';
			}else{
				echo 'false';
			}	
		}else{
			echo 'false';
		}
		
		die;
	}	
}